(function(){
	if(!window.cell) window.cell={};
	if(!window.cell.log) window.cell.log = function (str){
		Components.classes['@mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleService).logStringMessage(str);
	}
	if(!window.cell.zoom) window.cell.zoom=function (type){
		if ( window == this || !this.init ){
			return new cell.zoom(type);
		}
		return this.init(type);
	};
	cell.zoom.fn = cell.zoom.prototype = {
		obj: null,
		type: null,
		version: "2.0.0",
		svcContentPref: Components.classes["@mozilla.org/content-pref/service;1"].getService(Components.interfaces.nsIContentPrefService),
		init: function(type){
			if(type != "text" && type != "full"){
				return;
			}
			if(type == "text"){
				this.obj = gBrowser.selectedBrowser.markupDocumentViewer.textZoom;
				this.type = "browser.content.text-zoom";
			}
			if(type == "full"){
				this.obj = gBrowser.selectedBrowser.markupDocumentViewer.fullZoom;
				this.type = "browser.content.full-zoom";
			}
			return this;
		},
		customize: function(val){
			var val=val/100;
			if(!val){
				return this.svcContentPref.getPref(gBrowser.currentURI, this.type) * 100;
			}else{
				if (val == 1) {this.reset();return;}
				this.svcContentPref.setPref(gBrowser.currentURI, this.type, val);
				if(this.type == "browser.content.text-zoom"){
					gBrowser.selectedBrowser.markupDocumentViewer.textZoom = val;
				}
				if(this.type == "browser.content.full-zoom"){
					gBrowser.selectedBrowser.markupDocumentViewer.fullZoom = val;
				}
			}
		},
		reset: function(){
			this.svcContentPref.removePref(gBrowser.currentURI, this.type);
			if(this.type == "browser.content.text-zoom"){
				gBrowser.selectedBrowser.markupDocumentViewer.textZoom = 1;
			}
			if(this.type == "browser.content.full-zoom"){
				gBrowser.selectedBrowser.markupDocumentViewer.fullZoom = 1;
			}
		},
		up: function(val){
			if(!val){ var val = 5;}
			var current = this.svcContentPref.getPref(gBrowser.currentURI, this.type)*100;
			if(!current){var current = 100;}
			this.customize(current+val);
		},
		down: function(val){
			if(!val){ var val = 5;}
			var current = this.svcContentPref.getPref(gBrowser.currentURI, this.type)*100;
			if(!current){var current = 100;}
			this.customize(current-val);
		},
	}
})();